package com.mm.fam.web.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mm.fam.web.base.ResponseModel;
import com.mm.fam.web.entity.SysMenu;
import com.mm.fam.web.entity.ins.AuthMenuTreeIns;
import org.springframework.http.ResponseEntity;

import java.util.List;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author zt
 * @since 2018-09-29
 */
public interface SysMenuService extends IService<SysMenu> {

    /**
     * 保存
     *
     * @param menu
     * @return
     * @throws RuntimeException
     */
    ResponseEntity<ResponseModel<Object>> saveMenu(SysMenu menu);


    /**
     * 通过用户id获取菜单列表
     * @param userId
     * @return
     */
    List<SysMenu> getMenuByUserId(Integer userId);

    /**
     * 通过角色id获取菜单列表
     * @param roleId
     * @return
     */
    List<SysMenu> getMenuByRoleId(String roleId);

    /**
     * 通过角色ids获取菜单列表
     * @param roleIds
     * @return
     */
    List<SysMenu> getMenuByRoleIds(List<Integer> roleIds);


    /**
     * 通过用户id 查询菜单资源（树结构）
     * @param userId
     * @return
     */
    List<AuthMenuTreeIns> getMenuTreeByUserId(Integer userId);

    /**
     * 获取权限菜单树
     * @param menu 指定根菜单
     * @return
     */
    IPage<AuthMenuTreeIns> getMenuTree(SysMenu menu);




    /**
     * 查询
     *
     * @param pageNum
     * @param pageSize
     * @param search
     *            支持名称模糊查询
     * @return
     */
    IPage<SysMenu> page(int pageNum, int pageSize, String search, Integer parentId);


    /**
     * 批量删除菜单
     * @param ids,数组
     * @return
     */
    String deleteBatch(List<String> ids) throws  RuntimeException;

    /**
     * 根据用户id删除菜单列表
     * @param id
     * @return
     */
    boolean deleteMemuById(String id);

    ResponseEntity<ResponseModel<List<SysMenu>>> queryMenuTree(String search);

    ResponseEntity<ResponseModel<List<String>>> queryRoleOwnMenu(Integer roleId);

    ResponseEntity<ResponseModel<Object>> updateRoleOwnMenu(Integer roleId, String menuIds);

    ResponseEntity<ResponseModel<Object>> queryDynamicMenu(Integer roldId);

    List<Integer> queryOrganizationByUserId(Integer userId);

    ResponseEntity<ResponseModel<IPage<SysMenu>>> queryMenuList(Integer pageNo, Integer pageSize, String search);

    ResponseEntity<ResponseModel<List<SysMenu>>> queryParentMenuListNoPage();

    ResponseEntity<ResponseModel<List<SysMenu>>> queryChildrenMenuListNoPage();
}

